home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _542EB3CEFAEF4FEF9F199F89B8B702B1 < prev    next >
Encoding:
Text File  |  2004-01-06  |  6.5 KB  |  167 lines

  1. -- patroling behaviour - 
  2. -- Created by Sten; 09092002
  3. --------------------------
  4.  
  5.  
  6. AIBehaviour.OGPatrolNode = {
  7.     Name = "OGPatrolNode",
  8.     XTime = 0,
  9.     PathStep = 0,
  10.     PatrolPoints = {},
  11.     
  12.  
  13.     Sounds = {
  14.         Ivan = Sound:Load3DSound("SOUNDS/E3DIALOG/i_there_open_fire.wav"),
  15.         Ivan2 = Sound:Load3DSound("SOUNDS/E3DIALOG/i_i-see_him.wav"),
  16.         Steve = Sound:Load3DSound("SOUNDS/e3ai/hey_over_there.wav"),
  17.         Rob = Sound:Load3DSound("SOUNDS/E3DIALOG/r_i_see_him.wav"),
  18.         Rob2 = Sound:Load3DSound("SOUNDS/E3DIALOG/r_target.wav"),
  19.         Rob3 = Sound:Load3DSound("SOUNDS/E3DIALOG/r_move.wav"),
  20.         Ray = Sound:Load3DSound("SOUNDS/E3DIALOG/ry_there_he_is.wav"),
  21.         Ray2 = Sound:Load3DSound("SOUNDS/E3DIALOG/ry_over_there.wav"),
  22.         Ray3 = Sound:Load3DSound("SOUNDS/E3DIALOG/ry_open_fire.wav"),
  23.     },
  24.  
  25.     -- SYSTEM EVENTS            -----
  26.     
  27.     ---------------------------------------------
  28.     OnSpawn = function(self,entity )
  29.         local n = 0;
  30.         for n = entity.Properties.pathstart, entity.Properties.pathsteps, 1 do
  31.             tinsert(self.PatrolPoints,n);
  32.         end
  33.         self:AISF_PatrolPath(entity,sender);
  34.     end,
  35.     ---------------------------------------------
  36.     OnSelected = function(self,entity )
  37.     end,
  38.     ---------------------------------------------
  39.     OnActivate = function(self,entity )
  40. --        self:AISF_PatrolPath(entity,sender);
  41.     end,
  42.     ---------------------------------------------
  43.     OnNoTarget = function( self,entity )
  44. --        entity:SelectPipe(0,"standingthere");
  45.     end,
  46.     ---------------------------------------------
  47.     OnPlayerSeen = function( self,entity )
  48.         System:LogToConsole(entity:GetName().." .. Seen");
  49.         self.XTime = random(1,9);
  50.         if (self.XTime == 1) then
  51.             entity:Say(self.Sounds.Ivan);
  52.         elseif (self.XTime == 2) then
  53.             entity:Say(entity.Behaviour.Sounds.Ivan2);
  54.         elseif (self.XTime == 3) then
  55.             entity:Say(entity.Behaviour.Sounds.Steve);
  56.         elseif (self.XTime == 4) then
  57.             entity:Say(entity.Behaviour.Sounds.Rob);
  58.         elseif (self.XTime == 5) then
  59.             entity:Say(entity.Behaviour.Sounds.Rob2);
  60.         elseif (self.XTime == 6) then
  61.             entity:Say(entity.Behaviour.Sounds.Rob3);
  62.         elseif (self.XTime == 7) then
  63.             entity:Say(entity.Behaviour.Sounds.Ray);
  64.         elseif (self.XTime == 8) then
  65.             entity:Say(entity.Behaviour.Sounds.Ray2);
  66.         elseif (self.XTime == 9) then
  67.             entity:Say(entity.Behaviour.Sounds.Ray3);
  68.         end
  69.         AI:Signal(SIGNALFILTER_GROUPONLY, 1, "OnPlayerSeenByGroupMember", entity.id);
  70.         self:SurpriseAnimation(entity,sender);
  71.     end,
  72.     ---------------------------------------------
  73.     OnEnemySeen = function(self,entity )
  74.     end,
  75.     ---------------------------------------------
  76.     OnEnemyMemory = function(self,entity )
  77.     end,
  78.     ---------------------------------------------
  79.     OnInterestingSoundHeard = function(self,entity )
  80.         entity:SelectPipe(0,"AIS_investigate");
  81.     end,
  82.     ---------------------------------------------
  83.     OnThreateningSoundHeard = function( self,entity )
  84.         entity:SelectPipe(0,"AIS_investigateThreat");
  85.     end,
  86.     ---------------------------------------------
  87.     OnReload = function(self,entity )
  88.     end,
  89.     ---------------------------------------------
  90.     OnClipNearlyEmpty = function(self,entity )
  91.     --    System:LogToConsole(entity:GetName().." .. OnClipNearlyEmpty");    
  92.     end,
  93.     ---------------------------------------------
  94.     OnGroupMemberDied = function(self, entity, sender)
  95.         entity:SelectPipe(0,"AIS_TeamMemberDied", sender.id);
  96.     end,
  97.     ---------------------------------------------
  98.     OnNoHidingPlace = function(self, entity, sender )
  99.     end,    
  100.     ---------------------------------------------
  101.     OnReceivingDamage = function ( self, entity, sender)
  102.         -- called when the enemy is damaged
  103.         entity:SelectPipe(0,"AIS_SearchHide_and_Signal");
  104.     end,
  105.     ---------------------------------------------
  106.     OnPlayerSeenByGroupMember = function ( self, entity, sender)
  107. --        System:LogToConsole(entity:GetName().." .. OnPlayerSeenByGroupMember");        
  108.         if (entity ~= sender) then
  109.             entity:SelectPipe(0,"PlayerSeenByGroupMember", sender.id);
  110.         else
  111.         end
  112.     end,        
  113.     ----------------------------------------------------FUNCTIONS -------------------------------------------------------------
  114.     
  115.     AISF_CallForHelp = function (self, entity, sender)
  116.         System:LogToConsole(entity:GetName().." .. Got_CallForHelp");
  117.         local target = AI:GetAttentionTargetOf(sender.id);
  118.         System:LogToConsole(entity:GetName().." .. Got_CallForHelp"..target.id);
  119.         entity:SelectPipe(0,"AIS_InvestigateSenderTarget",target.id);
  120.     
  121.     end,
  122.     ------------------------------------------------------------------------
  123.     
  124.     AISF_GoOn = function (self, entity, sender)
  125.         self:AISF_PatrolPath(entity,sender);
  126.     end,
  127.     
  128.     ------------------------------------------------------------------------
  129.  
  130.     
  131.     AISF_PatrolPath = function (self, entity, sender)
  132.         local PrevStep = self.PathStep;
  133.                 
  134.         self.PathStep = tremove(self.PatrolPoints,random(1,(entity.Properties.pathsteps-entity.Properties.pathstart)));
  135.         tinsert(self.PatrolPoints,self.PathStep);
  136.         
  137.         
  138.         System:LogToConsole(entity:GetName().." .. Path Step"..self.PathStep);
  139.         
  140.         -- Guard Point 
  141.         AI:CreateGoalPipe(entity.Properties.pathname..self.PathStep.."OG_PatrolNode");
  142.         AI:PushGoal(entity.Properties.pathname..self.PathStep.."OG_PatrolNode","run",1,0);
  143.         AI:PushGoal(entity.Properties.pathname..self.PathStep.."OG_PatrolNode","bodypos",1,0);
  144.         AI:PushGoal(entity.Properties.pathname..self.PathStep.."OG_PatrolNode","timeout",1,1);
  145.         AI:PushGoal(entity.Properties.pathname..self.PathStep.."OG_PatrolNode","locate",1,entity.Properties.pathname..self.PathStep);
  146.         AI:PushGoal(entity.Properties.pathname..self.PathStep.."OG_PatrolNode","acqtarget",1,"");
  147.         AI:PushGoal(entity.Properties.pathname..self.PathStep.."OG_PatrolNode","approach",1,0);
  148.         AI:PushGoal(entity.Properties.pathname..self.PathStep.."OG_PatrolNode","timeout",1,0.5);
  149.         AI:PushGoal(entity.Properties.pathname..self.PathStep.."OG_PatrolNode","devalue",0);
  150.         AI:PushGoal(entity.Properties.pathname..self.PathStep.."OG_PatrolNode","timeout",1,3);
  151.         AI:PushGoal(entity.Properties.pathname..self.PathStep.."OG_PatrolNode","AIS_PatrolLook");
  152.         AI:PushGoal(entity.Properties.pathname..self.PathStep.."OG_PatrolNode","timeout",1,3);
  153.         AI:PushGoal(entity.Properties.pathname..self.PathStep.."OG_PatrolNode","signal",0,1,"AISF_PatrolPath",0);
  154.             
  155.         entity:SelectPipe(0,entity.Properties.pathname..self.PathStep.."OG_PatrolNode");
  156.     end,
  157.         
  158.     
  159.     ------------------------------------------------------------------------
  160.     SurpriseAnimation = function (self, entity, sender)
  161.         entity:StartAnimation(0,"recognition");
  162.         entity:SelectPipe(0,"AIS_Delay_1");
  163.     end,        
  164.     ------------------------------------------------------------------------
  165. }
  166.  
  167.